﻿
<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>创建生产计划</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <script src="~/js/layui/layui.js"></script>
    <link href="~/js/layui/css/layui.css" rel="stylesheet" />
    <link href="~/X-admin/css/xadmin.css" rel="stylesheet" />
    <script src="~/X-admin/js/jquery.min.js"></script>
    <script src="~/X-admin/js/xadmin.js"></script>
    <script src="~/js/framework/sysframework.js"></script>
    <script src="~/js/framework/commonjs.js"></script>
    <script src="~/js/sysweb/planjs.js"></script>
</head>
<body>
    <ul lay-bar="disabled" class="mWebBanner">
        <li class="layui-nav-item" style="float:left;">
            <button id="btn-update" type="button" name="btn_update" onclick="SaveCost()" class="buttonCss">
                <i class="layui-icon" style="margin-right:3px">&#x1005;</i>确认保存
            </button>
        </li>
      
        <li class="layui-nav-item" style="float:left;margin-left:3%">
            <button id="btn-sync" type="button" onclick="closeWin()" class="buttonCss">
                <i class="layui-icon" style="margin-right:3px">&#x1007;</i> 关闭页面
            </button>
        </li>
    </ul>
    <div style="height:800px;overflow-y: scroll;">
        <div class="layui-card" style="margin-top:1%">
            <div class="layui-card-body" style="padding-top:4%;">
                <form id="dForm" class="layui-form layui-col-space5">
              
              
            
               
                    <div class="layui-card-body layui-table-body layui-table-main" id="layui-table-main" >
                        <table class="layui-hide" id="list" lay-filter="list"></table> 
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-group" style="float:left;">
                            <div class="layui-input-prefix">
                                备注说明
                            </div>
                            <input type="text" id="memo" name="memo" class="layui-input" style="width:370%">
                        </div>
                    </div>
                </form>
            </div>
        </div>
   
    </div>
</body>
</html>

<script type="text/javascript">
    var mCodes = "";
    $(function () {
        mCodes = getUrlVariable("mCodes");
        loadData();
    });

    function loadData() {
        var dUrl = "../Plan/getDataList?dataType=psfl&condition=" + mCodes;
        layui.use(['table'], function () {
            var table = layui.table, form = layui.form;
            table.render({
                elem: '#list'
                , cols: [[ //标题栏
                    { field: 'proCode', title: '存货编码', width: 110 }
                    , { field: 'proName', title: '存货名称', width: 180 }
                    , { field: 'barCount', title: '件 数', width: 110 }
                    , { field: 'wuliufei', title: '物流费用', width: 110, edit: 'text' }
                    , { field: 'songhuofei', title: '送货费用', width: 110, edit: 'text' }
                ]], done: function (res, page, count) {
                    count = res.data.length;

                }
                , url: dUrl
                , skin: 'row' //表格风格
                , even: true
                , page: false //是否显示分页
            });
        });
    }

    function SaveCost() {
  
        layui.use('table', function () {
            var table = layui.table;
            var tableData = table.cache['list']; // 使用表格的id来获取数据
            var datas = new Array();
            tableData.forEach(function (item) {
                var obj = {
                    proCode: item.proCode,
                    wuliufei: item.wuliufei,
                    songhuofei: item.songhuofei,
                    barCount: item.barCount
                }
                datas.push(obj);
               
            });
            var memo = $("input[ name='memo']").val();
            $.ajax({
                url: "../Plan/AddPlanFreight",
                data: { datas: JSON.stringify(datas), mCodes: mCodes, memo: memo },
                type: "post",
                success: function (rsl) {
                    if (rsl.result) {
                        layer.msg("保存成功");
                    } else {
                        layer.msg(rsl.message);
                    }
                }
            });
        });
       
    }
</script>

